package com.collectplus.express.tools;

import java.net.URISyntaxException;
import java.text.MessageFormat;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import droid.frame.utils.android.Alert;


/**
 * 
 * @author wind
 * 
 */
public class CollectPointUtils {

	public static void goThere(Context context ,String la,String lo){
		String target = la+","+lo;
//		String target = order.getLatitude() + "," + order.getLongitude();
		// intent.putExtra("target", order.getAddress());
		String uriFormat = "intent://map/direction?" + //
				"destination=name=奥体中心|latlng:{0}&mode=walking&region=北京" + //
				"referer=收货宝|com.collectplus.express#Intent;scheme=bdapp;package=com.baidu.BaiduMap;end";
		try {
			Intent intent = new Intent();
			String uri = MessageFormat.format(uriFormat, target);
			intent = Intent.parseUri(uri, 0);
			context.startActivity(intent);
//			mContext.startActivityForResult(intent, 200);
		} catch (URISyntaxException e) {
			e.printStackTrace();
		} catch (ActivityNotFoundException e) {
			Alert.toast("无法查看路径, 请安装百度地图");
			// Intent intent = new Intent();
			// intent.setClass(fragment.getContext(), BaiduRoutePlanActivity.class);
			// intent.putExtra("target", target);
			// fragment.startActivity(intent);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	
	/**
	 * 复制到剪切版
	 * 
	 * @param context
	 * @param text
	 */
	public static void copyTest(Context context, String text) {
		if (android.os.Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.HONEYCOMB) {
			android.text.ClipboardManager clipboard = (android.text.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
			clipboard.setText(text);
		} else {
			android.content.ClipboardManager clipboard = (android.content.ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
			android.content.ClipData clip = android.content.ClipData.newPlainText("已复制到剪切板", text);
			clipboard.setPrimaryClip(clip);
		}
	}


}
